package com.ktjiaoyu.ch01_hello.repository;

import com.ktjiaoyu.ch01_hello.pojo.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @Entity generator.domain.User
*/
@Repository   //dao
public interface UserRepository extends JpaRepository<User,Long> , JpaSpecificationExecutor<User> {

    public List<User> findUserByUsrNameAndUsrPassword(String uname, String pwd);

    public List<User> findUserByUsrNameLike(String uname);

    //nativeQuery = true  支持原生sql  默认是 hql
    //@Query(value = "select * from sys_user where usr_role_id=?1",nativeQuery = true)
    /*@Query(value = "select u from User u where u.usrRoleId=:roleId")
    public List<User> findByUsrRoleId(Long roleId);*/

    Page<User> findPageByUsrRoleId(long l, Pageable pageable);
}
